Skip to content

Conversation

@gui1117
Copy link
Contributor

@gui1117 gui1117 commented Sep 10, 2025

I think the doc is wrong in regards to the spendable amount: the formula is wrong in some situations.
Also it says that reserved balances add a provider but the reality in the code is different:

#[test]
fn foo() {
	ExtBuilder::default().existential_deposit(10).build_and_execute_with(|| {
		let acc = 3456;
		Balances::set_balance(&acc, 100);
		Balances::set_balance(&2, 100);
		assert!(Balances::hold(&TestId::Foo, &acc, 10).is_ok());
		assert!(Balances::hold(&TestId::Foo, &acc, 90).is_err()); // No provider reference.
		assert!(Balances::hold(&TestId::Foo, &acc, 80).is_ok());
	});
}
#[test]
fn foo2() {
	ExtBuilder::default().existential_deposit(10).build_and_execute_with(|| {
		let acc = 3456;
		Balances::set_balance(&acc, 100);
		Balances::set_balance(&2, 100);
		System::inc_providers(&acc);
		assert!(Balances::hold(&TestId::Foo, &acc, 10).is_ok());
		assert!(Balances::hold(&TestId::Foo, &acc, 90).is_ok()); // Some provider reference.
	});
}

I have to look deeper to double check, but this is probably more correct than before.

@midegdugarova
Copy link
Contributor

thanks @gui1117 ! good catch

@gui1117
Copy link
Contributor Author

gui1117 commented Sep 22, 2025

don't merge as-is it was more a comment that a direct PR, I tried to improve the PR a bit, I am still not sure what is the exact spec, so I don't know what to write down.

Sometimes the account is dusted sometimes it is not. I couldn't find any consistency.

@CrackTheCode016
Copy link
Contributor

Hey @gui1117, thank you for this PR, any update on its status?

@gui1117
Copy link
Contributor Author

gui1117 commented Oct 1, 2025

When there is another provider, sometimes the amount below ED gets dusted sometimes not depending on the operation. A transfer will usually dust the account, reserve will not, I couldn't find any consistency, even the internal doc are contradictory so I reported this internally.
So the doc is ok for some cases and for some cases the dust doesn't get removed. As long as there is no actual specification I don't think I can improve the doc.

@gui1117 gui1117 closed this Oct 1, 2025
@gui1117 gui1117 deleted the patch-1 branch October 1, 2025 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants